Masking out-of-source-domain data points for nearest neighbour remapping #317
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When remapping to a larger domain with the method
nearest_s2d, data points outside the original domain will - by the nature of this method - be extrapolated, i. e. have values from the edge of the original domain.This PR introduces a
Regridderoption to apply a "domain mask" that is generated by creating remapping weights with thebilinearmethod as an extra step (while havingunmapped_to_nanactivated) before creating the nearest neighbour remapping weights. This way, all data points that would count asunmappedfor thebilinearmethod will also be masked fornearest_s2d.This is useful when remapping data on regional grids such as CORDEX data. A demonstration can be seen here at the bottom of
Masking.ipynb:https://github.com/sol1105/xESMF/blob/domain_mask/doc/notebooks/Masking.ipynb
I added it as an option to the
Regridderbut the linting suggests that the__init__method gets too complex with this addition. I could also add this masking option as a separate function orRegriddermethod. But before putting more work into this I would welcome your general feedback (and if you welcome the general idea of this masking option, also specific feedback on how to preferably deal with the complexity issue).